package client;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import br.edu.sistemaacademico.command.Command;


public class Client {

	public Client() {

    }
	public static Command getService(String service){
		try{
			//para nao usar rmiresgistry, adicione a linha abaixo
			Registry registry = LocateRegistry.getRegistry("localhost");
            //e troque a linha abaixo
            //IOlaMundo o = (IOlaMundo) Naming.lookup("rmi://localhost:1099/OlaMundoService");
            //pela linha abaixo
           // this.command = (Command) registry.lookup("OlaMundoService");
		return (Command) registry.lookup(service);
	} catch (NotBoundException e){
        System.out.println("NotBoundException: " + e.toString());
        }catch (RemoteException e) {
            System.out.println("RemoteException: " + e.toString());
        }catch (Exception e) {
            System.out.println("Erro: " + e.getMessage());
        }
	return null;
	}
}
